/**
 * @param {string[]} strs
 * @return {string}
 */
var longestCommonPrefix = function (strs) {
    if (strs.length < 0) {
        return "";
    }
    let pre = strs[0];
    for (let i = 0; i < strs.length; i++) {
        while (strs[i].indexOf(pre) !== 0) {
            pre = pre.substring(0, pre.length - 1);
        }
    }
    return pre;
};

console.log(longestCommonPrefix(["flower","flow","flight"]));